﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace JFLogic.Logic.Donee
{
    public class DoneeLogic
    {

        /// <summary>
        /// 获取可以受赠的受赠人
        /// </summary>
        /// <param name="integar"></param>
        /// <returns></returns>
        public TB_Donee GetCanTransferModel(int integra)
        {
            int restIntegar = 20000 - integra;
            return DB.Context.From<TB_Donee>()
                .Where(d => d.NewIntegra <= restIntegar)
                .OrderBy(d => new { d.OrderIndex, d.DoneeId })
                .First();
        }

        public TB_Donee GetModelByPhone(string phone)
        {
            return DB.Context.From<TB_Donee>()
                .Where(d => (d.Phone == phone))
                .First();
        }

        public TB_Donee GetModelById(int doneeId)
        {
            return DB.Context.From<TB_Donee>()
                .Where(d => (d.DoneeId == doneeId))
                .First();
        }

        public int Update(TB_Donee donee)
        {
            return DB.Context.Update<TB_Donee>(donee);
        }
    }
}
